<?php
include_once "top.php";
$userid = $_GET['userid'];
$shopid = $_GET['shopid'];
$totalscore = $_GET['totalscore'];
$totalnum = $_GET['totalnum'];
$selectedarray = json_decode($_GET['selectedarray'], true);
$postfee = 15;
if ($totalscore >= 40) {
    $postfee = 0;
}

$productList = array();
foreach($selectedarray as &$selected) {
    $product = $db->ig2_want('mae_admin_product', 'id = '.$selected['productid']);
    $product['num'] = $selected['num'];
    $product['selectedscore'] = $product['num'] * $product['score'];
    $productList[] = $product;
}

$shop=$db->ig2_want('mae_shop','admin_id="'.trim($userid).'"');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width" />
<meta content="telephone=no" name="format-detection" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<title>兑换清单</title>
<link href="css/discount.css" rel="stylesheet" type="text/css" />
<link href="css/common.css" rel="stylesheet" type="text/css" />
    <script src="inc/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function(){
			$("#commitbtn").click(function(){
                $(this).css({'background':'#F8D62E'});
				window.location.href = "shopowner_market_address.php?userid=" + $("#userid").val() + "&shopid=" + $("#shopid").val() + "&postfee=" + $("#postfee").val() + "&totalscore=" + $("#totalscore").val() + "&totalnum=" + $("#totalnum").val() + "&selectedarray=" + $("#selectedarray").val();
			});
        });
    </script>
</head>

<body>
<input type="hidden" id="userid" value="<?php echo($userid)?>" />
<input type="hidden" id="shopid" value="<?php echo($shop['id'])?>" />
<input type="hidden" id="postfee" value="<?php echo($postfee)?>" />
<input type="hidden" id="totalscore" value="<?php echo($totalscore)?>" />
<input type="hidden" id="totalnum" value="<?php echo($totalnum)?>" />
<input type="hidden" id="selectedarray" value='<?php echo($_GET['selectedarray'])?>' />
<div class="exchangelist2_body">
<div class="exchangelist2_con">
<div class="exchangelist2_con_title">兑换清单</div>
<div class="exchangelist2_con_productlist">
<ul>
    <?php
    foreach($productList as $product) {

    ?>
        <li>
            <div class="productlist_left"><img src="<?php echo($product['imgurl']) ?>" /></div>
            <div class="productlist_right">
                <div class="productlist_right1" style="width:100%;padding-left:0;font-size:18px;">名称：<?php echo($product['name']) ?></div>
                <div class="productlist_right2" style="font-size:18px;">数量：<?php echo($product['num']) ?></div>
                <div class="productlist_right3" style="font-size:18px;">积分：<?php echo($product['selectedscore']) ?></div>
            </div>
        </li>
    <?php
    }
    ?>

</ul>
</div>
<div class="exchangelist2_con_txt2">注：店长兑换实物商品需支付15积分作为运费，兑换满40积分免运费。当周球票最晚请于周三兑换。</div>
<div class="exchangelist2_con_txt3">
    <span>运费积分</span>
    <b><?php echo($postfee)?></b>
</div>
<div class="exchangelist2_con_txt3"><span>商品积分</span><b><?php echo($totalscore)?></b></div>
<div class="exchangelist2_con_txt4"><span>共消费积分</span><b><?php echo($totalscore + $postfee)?></b></div>
<div class="exchangelist2_con_btn"><a href="javascript:void(0)" id="commitbtn"><img src="images/btn_bg.png" />确认</a></div>
</div>
</div>
</body>
</html>
